// 语言包
var chi = require('../../utils/Chinese.js')
var eng = require("../../utils/English.js")
//获取应用实例
const app = getApp()
Page({

  /**
   * 页面的初始数据
   */
  data: {
    language: '',
    // 语言包对象
    content: '',
    // 订单信息
    // payment_result 支付结果 0 失败 1 成功
    order_infor:{ id: "0", url: "../../img/tuijian_03.jpg", name: "焦糖味糖浆 意大利原装", price: 127, capacity: '1000ml', number: "1",payment_result:'0'}

  },


  on: function () {
    let that = this

    // 初始化data
    that.setData({
      language: app.data.language,
    })
    var lastLanuage = that.data.language
    if (lastLanuage == 'zh_CN') {
        that.setData({
            content: chi.content,
          })
      wx.setNavigationBarTitle({
        title: 'Payment Result'
      })
    } else if (lastLanuage == 'zh_EN') {
        that.setData({
            content: eng.content,
          })
      // 修改导航标题
      wx.setNavigationBarTitle({
        title: 'Payment Result'
      })
    }

  },

  index:function(){
    wx.switchTab({
      url: '../index/index',
    })
  },
  order_infor:function(){
      wx.navigateTo({
        url: '../order_detail/order_detail',
      })
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    let that = this
    that.on()
    // 如果是支付失败更改支付金额值
    var order_infor = that.data.order_infor
    var payment_result = that.data.order_infor.payment_result
    if(payment_result == 0){
      order_infor.price = 0
      that.setData({
        order_infor:order_infor
      })
    }
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {
   
  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
    let that = this
    that.on()
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})